﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>请选择表单</title>
    
    <link href="../../DataUser/Style/ccbpm.css" rel="Stylesheet" />
    <link href="../../Scripts/layui/layui/css/layui.css" rel="stylesheet" />
    <script type="text/javascript" src="../../Scripts/QueryString.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-1.11.0.min.js"></script>
    <!-- 导入配置文件. -->
    <script type="text/javascript" src="../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../Comm/Gener.js"></script>
    <script src="../../Scripts/layui/layui/layui.js"></script>
    <script type="text/javascript">
        var workid = GetQueryString("WorkID");
        var flowNo = GetQueryString("FK_Flow");
        $(function () {

            // 初始化人员.   //开始加载数据.
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt");
            handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
            handler.AddPara("WorkID", GetQueryString("WorkID"));
            handler.AddPara("FID", GetQueryString("FID"));
            var data = handler.DoMethodReturnString("StartGuideFrms_Init");

            if (data.indexOf('err@') == 0) {
                document.getElementById("Msg").innerHTML = data;
                return;
            }


            data = JSON.parse(data);
            var frms = data.Frms;
            var flow = data.WF_Flow[0];
            var startGuidePara = GetPara(flow.AtPara, "StartGuidePara");
            var html = "<ul>";
            for (var i = 0; i < frms.length; i++) {

                var frm = frms[i];

                html += "<li style='line-height:30px'>";
                if (startGuidePara == 0) //选择单个表单发起
                    html += "<div class='layui-menu-body-title'><a href='../../MyFlow.htm?FK_Flow=" + flowNo + "&WorkID=" + workid + "&FK_Node=" + flowNo + "01&IsCheckGuide=1&Frms=" + frm.No + "' >" + frm.Name + "</a></div>";
                else
                    html += "<input type=checkbox id='" + frm.No + "' name='frms' lay-skin='primary'/>" + frm.Name;
                html += "</li>";
            }
            html += "<ul>";
            if (startGuidePara == 1)
                html += "<input type=button class='layui-btn layui-btn-normal  layui-btn-sm' style='margin-left:30px' value='发起流程' onclick='StartFlow()'/>";
            document.getElementById("docs").innerHTML = html;
            layui.form.render();
        });
        function StartFlow() {
            var workid = GetQueryString("WorkID");
            //获取选择的表单
            var checks = $("input[name='frms']:checked");
            if (checks.length == 0) {
                alert("至少请选择一个表单");
                return;
            }
            if (checks.length == 1) {
                SetHref("../../MyFlow.htm?FK_Flow=" + flowNo + "&WorkID=" + workid + "&FK_Node=" + flowNo + "01&IsCheckGuide=1&Frms=" + checks[0].id);
                return;
            }
            var frmIds = [];
            $.each(checks, function (i, item) {
                frmIds.push(item.id);
            });

            frmIds = frmIds.join(",");
            var gwf = new Entity("BP.WF.GenerWorkFlow", workid);
            gwf.SetPara("Frms", frmIds);
            gwf.Update();
            SetHref("../../MyFlowTree.htm?FK_Flow=" + flowNo + "&WorkID=" + workid + "&FK_Node=" + flowNo + "01");
            return;

        }
    </script>

    <style type="text/css">
        #tb_msg {
            height: 72px;
            width: 272px;
        }
    </style>
</head>
<body>

    <form class="layui-form" action="">
        <div class="layui-card">
            <div class="layui-card-header"><b>请选择表单</b></div>
            <div class="layui-card-body">
                <div id="docs"></div>
            </div>
        </div>

       
    </form>
</body>
</html>
